package com.zorn.platform.setting.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import com.zorn.core.provider.ServiceSupportProvider;
import com.zorn.platform.setting.service.ISettingService;
import com.zorn.platform.setting.dao.SettingDao;

@Service
public class SettingService extends ServiceSupportProvider implements ISettingService {

	/* Fields
	================================================== */
	private SettingDao settingDao;

	/* Methods
	================================================== */
	public List<Map<String, Object>> query(Map<String, Object> params) {
		List<Map<String, Object>> data = settingDao.query(params);

		return setQueryResult(isPaging() ? settingDao.count(params) : data.size(), data);
	}

	public int count(Map<String, Object> params) {
		return setCountResult(settingDao.count(params));
	}

	public String insert(Map<String, Object> params) {
		return setInsertResult(settingDao.insert(params), MapUtils.getString(params, "key"));
	}

	public int update(Map<String, Object> params) {
		return setUpdateResult(settingDao.update(params));
	}

	public int delete(Map<String, Object> params) {
		return setDeleteResult(settingDao.delete(params));
	}

	/* Getters & Setters
	================================================== */
	public void setSettingDao(SettingDao settingDao) {
		this.settingDao = settingDao;
	}

}